<?php
class DbHelper 
{
	const HOST = 'localhost';
	const UID = 'php_user';
	const PWD = 'dX8SHeAZnuhcAT54';
	const SCHEMA = 'cmx';

	// method to create Mysql connections
  	public static function createConnection() {
	  	try {
	  		// attempt to get connection to database from pool
			$connection = mysql_pconnect(self::HOST, self::UID, self::PWD);
			if (!$connection) { throw new Exception(mysql_error()); }
			
			// change to correct database
	  		$success = mysql_select_db(self::SCHEMA, $connection);
			if (!$success) { throw new Exception(mysql_error()); }
		} catch (Exception $e) {
			throw $e;
		}

		return $connection;
  	}
	
	public static function closeConnection($connection)
	{
		mysql_close($connection);
	}
}
?>
